#pragma once

#include "Include.h"

#include "UseCase.h"

namespace uml {

Include::Include(const QString& umlType)
    : NamedElement(umlType) {}

void Include::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    DirectedRelationship::fromJson(json, errorList);
    NamedElement::fromJson(json, errorList);
    addition_ = JsonSerializable::create<UseCase>(json.value("addition"), errorList);

    includingCase_ = JsonSerializable::create<UseCase>(json.value("includingCase"), errorList);

}

void Include::toJson(QJsonObject& json) {
    DirectedRelationship::toJson(json);
    NamedElement::toJson(json);
    if (addition_) {
        QJsonObject addition_json;
        addition_->toJson(addition_json);
        json.insert("addition", addition_json);
    }
    if (includingCase_) {
        QJsonObject includingCase_json;
        includingCase_->toJson(includingCase_json);
        json.insert("includingCase", includingCase_json);
    }
}

/// <summary>
/// addition getter
/// The UseCase that is to be included.
/// </summary>
shared_ptr<UseCase> Include::addition() const {
    return addition_;
}

/// <summary>
/// addition setter
/// The UseCase that is to be included.
/// </summary>
void Include::setAddition(shared_ptr<UseCase> value) {
    addition_ = value;
}

/// <summary>
/// includingCase getter
/// The UseCase which includes the addition and owns the Include relationship.
/// </summary>
shared_ptr<UseCase> Include::includingCase() const {
    return includingCase_;
}

/// <summary>
/// includingCase setter
/// The UseCase which includes the addition and owns the Include relationship.
/// </summary>
void Include::setIncludingCase(shared_ptr<UseCase> value) {
    includingCase_ = value;
}

} // namespace uml
